home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / Mac F2C 1.2.2 / Mac F2C Documentation / INSTRUCTIONS (Symantec) < prev    next >
Encoding:
Text File  |  1995-08-02  |  29.6 KB  |  651 lines  |  [TEXT/KAHL]

  1.         *************************************************
  2.         *************************************************
  3.  
  4.           INSTRUCTIONS FOR SETTING UP AND USING Mac F2C 
  5.  
  6.                WITH SYMANTEC C/C++ OR THINK C/C++
  7.  
  8.         *************************************************
  9.         *************************************************
  10.  
  11.  
  12.  
  13. Before you can use the code produced by Mac F2C, you must set up and build 
  14. all of the required support libraries.  There are also special rules that 
  15. must be followed when using code produced by Mac F2C.  The process and 
  16. rules are slightly different for Symantec's compilers and for MetroWerk's 
  17. CodeWarrior.  These instructions are for setting up Mac F2C for use with 
  18. Symantec C/C++ for PPC and/or THINK C/C++ for 68K.  Refer to the 
  19. documentation file "INSTRUCTIONS (CodeWarrior)" for instructions on how to 
  20. set things up for use with MetroWerk CodeWarrior.
  21.  
  22. USERS UPGRADING FROM VERSION 1.2 or prior: You need to re-install ALL 
  23. libraries and project files, including main.c and f2c.h.  There have been 
  24. subtle changes in source code to accomodate Symantec v8 (both PPC code 
  25. generation and changes in THINK libraries and headers in the version of 
  26. THINK that comes with Symantec v8).  Major changes are:
  27.  
  28.     (a) Do NOT place the source code to the Mac F2C Libraries in the 
  29.         Symantec/THINK Project Manager tree.  There are name conflicts 
  30.         between the files in libI77/libF77 and some of the new universal 
  31.         header files and PPC support files.  This means you must build 
  32.         the F2C libraries _first_ and then copy the built libraries into 
  33.         the Symantec/THINK Project Manager tree.
  34.         
  35.     (b) To accomodate PPC versions, the THINK libraries 'libI77a', 
  36.         'libI77b', and 'libF77' have been renamed 'libI77a 68K', 
  37.         'libI77b  68K', and 'libF77 68K'.  You may either modify your 
  38.         existing projects or simply rename these libraries to their 
  39.         old names after you have built them.
  40.         
  41.     (c) There are two sets of THINK supporting material, one for THINK v7 
  42.         sold as such or upgraded from v6 (including THINK v7 with the on-
  43.         line update to v8 translators), and the other for THINK v7 as 
  44.         supplied with Symantec C/C++ v8.  Please use the latter if (and 
  45.         only if) your copy of THINK came off the Symantec v8 package.  
  46.         
  47.         The supporting materials are different because the vendor supplied 
  48.         libraries are somewhat different between the THINK that comes out 
  49.         of a THINK v7 box (or is upgraded to v7 using on-line upgrades) 
  50.         and the THINK that comes out of a Symantec v8 box.
  51.  
  52. All of the THINK project files shipped with Mac F2C are for the THINK 
  53. Project Manger (TPM) version 7.  If you are using an earlier version of 
  54. THINK, please refer to the additional instructions in the folder "For THINK 
  55. v6 and Earlier Users".
  56.  
  57. All of the Symantec project files shipped with Mac F2C are for the Symantec 
  58. Project Manager (SPM) version 8.0.1.  They cannot be opened by SPM v8.0.  
  59. If you have v8.0, I (and Symantec) urge you to upgrade to 8.0.1 using the 
  60. free updaters available at major archive sites.
  61.  
  62.  
  63. The instructions here are broken into four sections:
  64.  
  65.     A.  Setting up Mac F2C for...
  66.     
  67.         A1. ...for SPM
  68.     
  69.         A2. ...for TPM v7 (shipped with Symantec v8)
  70.     
  71.         A3. ...for TPM v7 (plain, not shipped with Symantec v8)
  72.     
  73.     B.  Verifying correct operation
  74.     
  75.     C.  Translating with Mac F2C
  76.     
  77.     D.  Using C code produced by Mac F2C
  78.     
  79.     
  80.     
  81. *****************************************************************************
  82.  
  83.  
  84. A1.  Setting Up Mac F2C for SPM
  85. *******************************
  86.  
  87. Follow these instructions to set up Mac F2C for use with the Symantec 
  88. Project Manager (SPM v8) generating PPC native code.
  89.  
  90.  
  91. Step 1:  BRING ALL THE LIBRARIES UP-TO-DATE
  92.  
  93. The easy way to bring the F2C libraries up to date is to use the provided 
  94. AppleScript.  In the folder "SPM Support" is the executable AppleScript 
  95. "Build F2C Libs for SPM".  Double-click this file to start the script.  
  96. Follow the directions of the prompts.  All required libraries will be 
  97. brought up to date.
  98.  
  99. If this fails or for any reason you wish to bring them up to date 
  100. manually, simply follow this algorithm:
  101.  
  102. FOR the project files:
  103.     (1) "libI77 PPC"   in the "Mac F2C Libraries" folder
  104.     (2) "libF77 PPC"   in the "Mac F2C Libraries" folder
  105. REPEAT the following steps:
  106.     (a) Double-click on the project file.  
  107.     (b) In the Symantec Project Manager's "Build" menu, select the 
  108.         "Build Library" command.  
  109.     (c) When finished, select the "Remove Objects" command in the 
  110.         "Build" menu.  
  111. END FOR-REPEAT
  112.  
  113.  
  114. Step 2:  MOVE THINGS TO THE RECOMMENDED LOCATIONS
  115.  
  116. For easiest and smoothest operation, the remaining files should be 
  117. installed as follows: 
  118.  
  119. (1) Drag the two static (XCOFF) library files in the folder "Mac F2C 
  120.     Libraries" ('libI77 PPC.o' & 'libF77 PPC.o'; the same ones you 
  121.     just built in Step 2 above) to the folder that contains 
  122.     the SPM.  You may put them inside a folder within the SPM folder 
  123.     if you so desired.  *** WARNING ***  Do not place the source code 
  124.     for these libraries (found in the folders "libF77 Sources" and 
  125.     "libI77 Sources") in the Symantec Project Manager Folder tree.  The 
  126.     source code for these libraries has name conflicts with Apple's 
  127.     Universal   Headers (e.g., a file called "fp.h" appears in both but 
  128.     the two are NOT equivalent files.  Otherwise any of your code that 
  129.     #includes any of the conflicted files may inadvertently access the 
  130.     wrong file.
  131.  
  132. (2) The folder "For '(Project Models)'" contains two model project folders 
  133.     called "SPM Mac F2C C Project" and "SPM Mac F2C C++ Project".  Drag 
  134.     both folders to the "(Project Models)" folder located in the same folder 
  135.     as the SPM (if you don't plan to use Mac F2C with the C++ compiler, 
  136.     you don't need the "SPM Mac F2C C++ Project" folder).  
  137.  
  138.     
  139.      
  140. *****************************************************************************
  141.  
  142.  
  143. A2.  SETTING UP Mac F2C for TPM v7 (shipped with Symantec v8)
  144. *************************************************************
  145.  
  146. Follow these instructions if your installation of the THINK Project Manager 
  147. came from the Symantec v8 package.  If you have any other version of THINK 
  148. (including any version updated to the v8 level using the free updaters), 
  149. follow the instructions in Section A3. "Setting up Mac F2C for TPM v7 
  150. (plain, not shipped with Symantec v8)"
  151.  
  152. Step 1:  PRELIMINARIES
  153.  
  154. All the files and folders you need are contained in the folder "For THINK 
  155. v7 shipped with Sym 8" (which is located in the folder "TPM Support" within 
  156. the folder "Symantec/THINK Support").  Unless otherwise indicated, all 
  157. files and folders referred to in the following sections are located in this 
  158. folder.  TPM refers to the THINK Project Manager.
  159.  
  160. (1) The folder "For 'Standard Libraries'"  contains four TPM project 
  161.     files:  "ANSI F2C", "unix F2C", "IOStreams F2C", and "CPlusLib F2C".  
  162.     Drag these files (NOT the folder itself) to the "Standard Libraries" 
  163.     folder located in the same folder as the TPM application.  If you 
  164.     don't have the THINK C++ compiler (or you don't plan to use Mac F2C 
  165.     with it) you do not need "IOStreams F2C" or "CPlusLib F2C".
  166.  
  167. (2) The folder "For folder containing TPM" contains two TPM projects 
  168.     ("Build 68K PCHs for F2C.π" and "Build Standard 68K PCHs.π") used 
  169.     to create customized versions of MacHeaders and MacHeaders++ and to 
  170.     then restore the original versions of these.  Drag these two files 
  171.     (NOT the folder itself) to the folder containing the TPM application.
  172.  
  173.  
  174. Step 2:  BRING ALL THE LIBRARIES UP-TO-DATE
  175.  
  176. The easy way to bring the F2C libraries up to date is to use the provided 
  177. AppleScript.  In the folder "For THINK v7 shipped with Sym 8" is the 
  178. executable AppleScript "Build F2C Libs for TPM".  Double-click this file to 
  179. start the script.  Follow the directions of the prompts.  All required 
  180. libraries will be brought up to date.
  181.  
  182. If this fails or for any reason you wish to bring them up to date 
  183. manually, simply follow this algorithm:
  184.  
  185. BUILD CUSTOM PCHs
  186.     Double click on "Build 68K PCHs for F2C.π"
  187.     Precompile "Mac #includes.c" to "MacHeaders" replacing the old one
  188.     Precompile "Mac #includes.cp" to "MacHeaders++" replacing the old one (only for C++)
  189. End BUILD CUSTOM PCHs
  190.  
  191. FOR the project files:
  192.     (1) "libI77a 68K"   in the "Mac F2C Libraries" folder
  193.     (2) "libI77b 68K"   in the "Mac F2C Libraries" folder
  194.     (3) "libF77 68K"    in the "Mac F2C Libraries" folder
  195.     (4) "ANSI F2C"      in the "Standard Libraries" folder
  196.     (5) "unix F2C"      in the "Standard Libraries" folder
  197.     (6) "IOStreams F2C" in the "Standard Libraries" folder (only for C++)
  198.     (7) "CPlusLib F2C"  in the "Standard Libraries" folder (only for C++)      
  199. REPEAT the following steps:
  200.     (a) Double-click on the project file.  
  201.     (b) In the THINK Project Manager's "Source" menu, select the 
  202.         "Make" command.  
  203.     (c) Uncheck the "Quick Scan" check-box.  
  204.     (d) Click on the "Use Disk" button.  
  205.     (e) Click on the "Make" button.
  206. END FOR-REPEAT
  207.  
  208. BUILD STANDARD PCHs
  209.     Double click on "Build Standard 68K PCHs.π"
  210.     Precompile "Mac #includes.c" to "MacHeaders" replacing the old one
  211.     Precompile "Mac #includes.cp" to "MacHeaders++" replacing the old one (only for C++)
  212. End BUILD STANDARD PCHs
  213.  
  214.  
  215. Step 3:  MOVE THINGS TO THE RECOMMENDED LOCATIONS
  216.  
  217. For easiest and smoothest operation, the remaining files should be 
  218. installed as follows: 
  219.  
  220. (1) Drag the three TPM project files in the folder "Mac F2C Libraries" 
  221.     ('libI77a 68K', 'libI77b 68K', & 'libF77 68K'; the same ones you 
  222.     brought up-to-date in Step 2 above) to the folder that contains 
  223.     the TPM.  You may put them inside a folder within the TPM folder 
  224.     if you so desired.  *** WARNING ***  Do not place the source code 
  225.     for these libraries (found in the folders "libF77 Sources" and 
  226.     "libI77 Sources") in the THINK Project Manager Folder tree.  The 
  227.     source code for these libraries has name conflicts with Apple's 
  228.     Universal Headers (e.g., a file called "fp.h" appears in both but 
  229.     the two are NOT equivalent files.  Otherwise any of your code that 
  230.     #includes any of the conflicted files may inadvertently access the 
  231.     wrong file.
  232.  
  233. (2) The folder "For '(Project Models)'" (located one level up in the 
  234.     "TPM Support Folder") contains two model project folders called 
  235.     "TPM Mac F2C C Project" and "TPM Mac F2C C++ Project".  Drag both 
  236.     folders to the "(Project Models)" folder located in the same folder 
  237.     as the TPM (if you don't have THINK C++ or don't plan to use Mac F2C 
  238.     with the C++ compiler, you don't need the "TPM Mac F2C C++ Project" 
  239.     folder).  
  240.  
  241.     
  242.      
  243.  
  244. *****************************************************************************
  245.  
  246.  
  247.  
  248. A3.  SETTING UP Mac F2C for TPM (plain, not shipped with Symantec v8)
  249. *********************************************************************
  250.  
  251. Follow these instructions if:
  252.     (a) You have THINK v7 purchased as such (not the version included 
  253.         with Symantec v8).
  254.     (b) You upgraded THINK v6 to THINK v7 using the free upgrades.
  255.     (c) You upgraded any version of THINK v7 to THINK "v7+" using the
  256.         free Symantec upgrades that bring you up to the THINK released
  257.         with Symantec v8.
  258.         
  259. If you have the version of THINK that came with Symantec v8, follow the 
  260. instructions in Section A2.  "SETTING UP Mac F2C for TPM v7 (shipped with 
  261. Symantec v8)"
  262.  
  263. If you have an earlier version of THINK than v7, refer to the documentation 
  264. file "For THINK v6 and Earlier Users".
  265.     
  266.     
  267. Step 1:  PRELIMINARIES
  268.  
  269. All the files and folders you need are contained in the folder "For plain 
  270. THINK v7" (which is located in the folder "TPM Support" within the folder 
  271. "Symantec/THINK Support").  Unless otherwise indicated, all files and 
  272. folders referred to in the following sections are located in this folder.  
  273. TPM refers to the THINK Project Manager.
  274.  
  275. (1) The folder "For 'Standard Libraries'"  contains four TPM project 
  276.     files:  "ANSI F2C", "unix F2C", "IOStreams F2C", and "CPlusLib F2C".  
  277.     Drag these files (NOT the folder itself) to the "Standard Libraries" 
  278.     folder located in the same folder as the TPM application.  If you 
  279.     don't have the THINK C++ compiler (or you don't plan to use Mac F2C 
  280.     with it) you do not need "IOStreams F2C" or "CPlusLib F2C".
  281.  
  282. (2) You need to fix a bug in one of the header files supplied with THINK.  
  283.     In the folder Standard Libraries, you will find the file "fltpnt.h".  
  284.     Open it and comment out or delete the following two lines:
  285.  
  286.         typedef float float_t;
  287.         typedef double double_t;
  288.  
  289.     These lines are not only unnecessary, but actually wrong when doubles 
  290.     are 8-bytes long.  Notice that "fltpnt.h" includes the file "SANE.h" 
  291.     which in turn includes "Types.h".  "Types.h" contains the correct 
  292.     definitions of float_t and double_t.  Thus, the above two lines can be 
  293.     safely deleted.  Symantec has incorporate this fix in the version of 
  294.     "fltpnt.h" supplied with Symantec C/C++ v8.
  295.     
  296.  
  297. Step 2:  BRING ALL THE LIBRARIES UP-TO-DATE
  298.  
  299. The easy way to bring the F2C libraries up to date is to use the provided 
  300. AppleScript.  In the folder "For plain THINK v7 " is the executable 
  301. AppleScript "Build F2C Libs for THINK".  Double-click this file to start 
  302. the script.  Follow the directions of the prompts.  All required libraries 
  303. will be brought up to date.
  304.  
  305. If this fails or for any reason you wish to bring them up to date 
  306. manually, simply follow this algorithm:
  307.  
  308. FOR the project files:
  309.     (1) "libI77a 68K"   in the "Mac F2C Libraries" folder
  310.     (2) "libI77b 68K"   in the "Mac F2C Libraries" folder
  311.     (3) "libF77 68K"    in the "Mac F2C Libraries" folder
  312.     (4) "ANSI F2C"      in the "Standard Libraries" folder
  313.     (5) "unix F2C"      in the "Standard Libraries" folder
  314.     (6) "IOStreams F2C" in the "Standard Libraries" folder (only for C++)
  315.     (7) "CPlusLib F2C"  in the "Standard Libraries" folder (only for C++)      
  316. REPEAT the following steps:
  317.     (a) Double-click on the project file.  
  318.     (b) In the THINK Project Manager's "Source" menu, select the 
  319.         "Make" command.  
  320.     (c) Uncheck the "Quick Scan" check-box.  
  321.     (d) Click on the "Use Disk" button.  
  322.     (e) Click on the "Make" button.
  323. END FOR-REPEAT
  324.  
  325.  
  326. Step 3:  MOVE THINGS TO THE RECOMMENDED LOCATIONS
  327.  
  328. For easiest and smoothest operation, the remaining files should be 
  329. installed as follows: 
  330.  
  331. (1) Drag the three TPM project files in the folder "Mac F2C Libraries" 
  332.     ('libI77a 68K', 'libI77b 68K', & 'libF77 68K'; the same ones you 
  333.     brought up-to-date in Step 2 above) to the folder that contains 
  334.     the TPM.  You may put them inside a folder within the TPM folder 
  335.     if you so desired.  *** WARNING ***  Do not place the source code 
  336.     for these libraries (found in the folders "libF77 Sources" and 
  337.     "libI77 Sources") in the THINK Project Manager Folder tree.  The 
  338.     source code for these libraries has name conflicts with Apple's 
  339.     Universal Headers (e.g., a file called "fp.h" appears in both but 
  340.     the two are NOT equivalent files.  Otherwise any of your code that 
  341.     #includes any of the conflicted files may inadvertently access the 
  342.     wrong file.
  343.  
  344. (2) The folder "For '(Project Models)'" (located one level up in the 
  345.     "TPM Support Folder") contains two model project folders called 
  346.     "TPM Mac F2C C Project" and "TPM Mac F2C C++ Project".  Drag both 
  347.     folders to the "(Project Models)" folder located in the same folder 
  348.     as the TPM (if you don't have THINK C++ or don't plan to use Mac F2C 
  349.     with the C++ compiler, you don't need the "TPM Mac F2C C++ Project" 
  350.     folder).  
  351.  
  352.     
  353.      
  354.  
  355. *****************************************************************************
  356.  
  357.  
  358. B.  VERIFYING CORRECT OPERATION OF Mac F2C
  359. ******************************************
  360.  
  361. The folder "Test Project ƒ" contains the following files:
  362.  
  363. (1)  "test.f" -- a sample FORTRAN program.
  364.  
  365. (2)  "main.c" -- the main program required to run programs produced
  366.      by Mac F2C, suffixed to compile with C.
  367.     
  368. (3)  "main.cp" -- the main program required to run programs produced
  369.      by Mac F2C, suffixed to compile with C++.
  370.      
  371. (4)  "f2c.h" -- an include file required to compile programs produced 
  372.      by Mac F2C.
  373.  
  374. (5)  "test.c (C Output)" -- what you should get when you translate 
  375.      the sample FORTRAN code files.
  376.  
  377. (6)  "Test.68K.π" -- a TPM v7.0.4 project to run the sample C program.
  378.   
  379. (7)  "Test.PPC.π" -- an SPM v8.0 project to run the sample C program.
  380.   
  381. (8)  "test.c (C++ Output)" -- what you should get when you translate 
  382.      the sample FORTRAN code files and select the C++ output option.
  383.  
  384. (9)  "Test++.68K.π" -- a TPM v7.0.4 project to run the sample C++ program.
  385.     
  386. (10) "Test++.PPC.π" -- an SPM v8.0 project to run the sample C++ program.
  387.  
  388. (11) "Test.*.µ" -- various CodeWarrior project files (not used)
  389.     
  390. Translate the sample FORTRAN program "Test.f" simply by dragging it onto 
  391. Mac F2C.  Do not change any of the options (use "Factory Defaults").  Once 
  392. you have done this you can compare it with "Test.c (C Output)" to verify 
  393. that you got the same thing.  If so, double click on the TPM or SPM project 
  394. file ("Test.68K.π" or "Test.PPC.π") and run it to verify correct operation.
  395.  
  396. If you also plan to use Mac F2C with the C++ compiler, you can run a second 
  397. test to verify correct operation with the C++ compiler.  Start Mac F2C and 
  398. in the "C Options" dialog, select "C++ code".  Do not change any of the 
  399. other options.  Translate "Test.f".  Compare it with "Test.cp (C++ Output)" 
  400. to verify that you got the same thing.  If so, double click on the TPM or 
  401. SPM project file ("Test++.68K.π" or "Test++.PPC.π") and run it to verify 
  402. correct operation.
  403.  
  404.  
  405.  
  406.  
  407.  
  408. *****************************************************************************
  409.  
  410.  
  411. C.  TRANSLATING FORTRAN PROGRAMS
  412. ********************************
  413.  
  414. You can use Mac F2C to translate FORTRAN to C using three methods:
  415.  
  416. (a) Start up Mac F2C and select the "Translate" command in the File menu.  
  417.     
  418. (b) Drag-&-drop a bunch of FORTRAN files onto Mac F2C.
  419.  
  420. (c) Use a scripting language (e.g., AppleScript) to send Mac F2C either an 
  421.     'open' command, an 'f2c' command, or a 'translate' command.  For more 
  422.     information on driving Mac F2C from a script see the instructions in 
  423.     the folder "Mac F2C AppleEvents".
  424.  
  425. FORTRAN files must be TEXT files and *must* end in ".f" or ".F" (sorry, but 
  426. the ending is determined by the unix f2c kernel -- it rejects files handed 
  427. to it with any other endings).  The output file is the same name with a 
  428. ".c" extension if you selected C code for the output, or the same name with 
  429. a ".cp" extension if you selected C++ code for the output.
  430.  
  431. The first five items in the Options menu let you control the various 
  432. translation and code generation options.  If you check the "Make these the 
  433. new defaults" box before clicking the "OK" button, your option selections 
  434. will be saved in a Preference file and used again the next time you start 
  435. Mac F2C.
  436.  
  437. If you do not understand what an option means, check the balloon help.  The 
  438. help balloons provide more detailed explanations of what each option means.  
  439. They also explain why dimmed options are not available and what you can do 
  440. to make them available.
  441.  
  442. The last item in the Options menu ("Mac F2C Preferences…") lets you control 
  443. how Mac F2C operates.  This dialog lets you control:
  444.  
  445.     - How Mac F2C behaves after having been launched with a drag-&-drop.
  446.     
  447.     - Whether the "Advanced Options" dialog will have an edit text field 
  448.       that allows you to enter unix option switches directly.
  449.       
  450.     - The creator type for all of the output files (determines their icon).
  451.     
  452.     - Whether and how Mac F2C interacts with THINK and/or CodeWarrior.  If 
  453.       the notify option is checked, Mac F2C will attempt to touch the 
  454.       corresponding THINK or CodeWarrior project file after translating a 
  455.       FORTRAN file into C successfully.  If THINK/CodeWarrior is not running 
  456.       or if the file is not part of the current project, Mac F2C will fail 
  457.       silently.  If the make option is checked, then Mac F2C will also send 
  458.       a make (e.g., bring up to date) command to THINK/CodeWarrior.  If a 
  459.       group of FORTRAN files are translated at once (via a drag-&-drop or 
  460.       via an AppleScript), the make command is not sent until the last file 
  461.       is translated.  Again, Mac F2C fails silently if THINK or CodeWarrior 
  462.       can't do it.
  463.       
  464.       Version 1.2.1 does *not* interact with the Symantec Project Manager.
  465.       This deficiency will be corrected in a future version of Mac F2C.
  466.       
  467. As in the case of the other option dialogs, check the balloon help if you 
  468. do not understand what an option means.  
  469.        
  470.  
  471.  
  472.  
  473. *****************************************************************************
  474.  
  475.  
  476. D.  USING C CODE PRODUCED BY MAC F2C
  477. ************************************
  478.  
  479. Part 1.  Generating 68K code using THINK C/C++
  480. ++++++++++++++++++++++++++++++++++++++++++++++
  481.  
  482. The C code produced by Mac F2C has the following compile and link 
  483. requirements for generating 68K code using THINK C/C++:
  484.  
  485.     - the header file "f2c.h"
  486.     - the F2C libraries "libI77a 68K", "libI77b 68K", and "libF77 68K"
  487.     - the C libraries "ANSI F2C" and "unix F2C"
  488.     - the C++ libraries "IOStreams F2C" and "CPlusLib F2C" (C++ only)
  489.     - 4-byte integers (C only)
  490.     - 8-byte doubles
  491.     - native floating-point format
  492.     - far code
  493.     - far data
  494.     - C++ ANSI conformance UNCHECKED (C++ only)
  495.     
  496. In addition, if you compile a stand-alone FORTRAN program (instead of only 
  497. some FORTRAN subroutines) you must include "main.c" in your project (or 
  498. "main.cp" if you use C++; the two files are identical).  This is because 
  499. the original main routine in the FORTRAN program becomes a function that is 
  500. called by main.c.  In addition, main.c performs a series of initializations 
  501. (primarily related to error catching) prior to executing the main FORTRAN 
  502. program.
  503.  
  504. The model project provided ("TPM Mac F2C C Project") is a folder that 
  505. contains everything you need to compile and run code produced by Mac F2C 
  506. using the C compiler.  This folder has a copy of main.c, f2c.h, and a 
  507. project file that includes the appropriate libraries and option settings.
  508.  
  509. The C++ model project ("TPM Mac F2C C++ Project") is a folder that contains 
  510. everything you need to compile and run code produced by Mac F2C using the 
  511. C++ compiler.  This folder has a copy of main.cp, f2c.h, and a project file 
  512. that includes the appropriate libraries and option settings.
  513.  
  514. If you have THINK C version 7.0 or better, simply create a new project by 
  515. using the "New Project" command in the THINK Project Manager's "File" menu 
  516. and selecting "TPM Mac F2C C Project" or "TPM Mac F2C C++ Project" as the 
  517. model for the new project.  Add your code files as appropriate, bring it 
  518. up-to-date (you may need to use the "Make" command and the "Use Disk" 
  519. option the first time), and run.
  520.  
  521. If you have an earlier version of THINK C, first replace the project file 
  522. provided in "Mac F2C C Project" with one made with your version of THINK (I 
  523. have included a list of the project contents for your convenience -- see 
  524. the additional instructions in the file "For THINK v6 and Earlier Users" if 
  525. you have trouble doing this).  Do not include any objects at this time.  To 
  526. start a new project, duplicate the entire "Mac F2C C Project" folder, 
  527. change the names of files and folders as appropriate, add your code files, 
  528. and bring everything up-to-date.
  529.  
  530. If you compile a FORTRAN subroutine or function that you want to call from 
  531. a C program, look at the C code produced by Mac F2C to see the appropriate 
  532. calling protocol.  You may or may not need to include the F2C support 
  533. libraries ("libF77 68K", "libI77a 68K", and "libI77b 68K").  In rare cases, 
  534. you may also need to copy some of the initialization code from "main.c" to 
  535. your calling program.
  536.  
  537. As noted above, code produced by Mac F2C *MUST* be compiled with 4-byte 
  538. integers.  This requirement cannot be relaxed.  The other requirements 
  539. (8-byte doubles, native floating-point format, far data, and far code) can 
  540. sometimes be relaxed:
  541.  
  542.     - IF you do not use doubles/reals in any situation where their size 
  543.       relative to integers matters (e.g., if you do not use doubles/reals 
  544.       in equivalence and common statements), then your code probably does
  545.       not require 8-byte doubles.  You need to verify this on a case-
  546.       by-case basis.
  547.         
  548.       This requirement exists because Mac F2C follows FORTRAN sizing 
  549.       rules when compiling FORTRAN code: sizeof(real) == sizeof(integer) 
  550.       and sizeof(double) == 2*sizeof(real).  FORTRAN real is compiled as 
  551.       C float and FORTRAN double as C double, so doubles have to be
  552.       8-bytes long for equivalence and common statements to be properly 
  553.       aligned.  There are a few other cases where the size of double 
  554.       variables matters; see AT&T Computing Science Technical Report 
  555.       No. 149 (included with Mac F2C) for a detailed discussion.
  556.         
  557.     - IF you compile your program with the option "Local variables are 
  558.       automatic" and you do not have large static data structures, you 
  559.       *might* not need "Far Data".  You need to verify this on a case-
  560.       by-case basis.
  561.         
  562.       Mac F2C creates large static data structures for I/O.  If you create 
  563.       local variables in the global area (static instead of automatic) or 
  564.       if you have other static data, you will almost certainly require 
  565.       "Far Data".  The I/O data structures can be large enough that you may 
  566.       require "Far  Data" for that reason alone.  
  567.         
  568.     - IF your program is not very large and doesn't have a large number of 
  569.       subroutines, you probably will not need "Far Code".  You need to verify 
  570.       this on a case-by-case basis.
  571.         
  572.       Mac F2C tends to produced redundant copies of utility code (especially 
  573.       code for performing array indexing).  It can also produce large numbers 
  574.       of auxiliary functions.  The result is that "Far Code" is often 
  575.       required.  Compile first with "Far Code", then check the code size and 
  576.       jump table to see if you can relax this requirement.
  577.         
  578.     - IF your program will NOT be compiled under THINK C++ (i.e., you chose 
  579.       K&R C or ANSI C output instead of C++ output) and you will  not link 
  580.       with code produced by THINK C++, you do not need native floating-point 
  581.       format.  The native floating-point format option is selected only to 
  582.       guarantee compatibility with the THINK C++ compiler should you chose to 
  583.       use the output of Mac F2C with C++ code.
  584.         
  585. If you change the "8-byte doubles", "native floating-point format", "Far 
  586. Code", or "Far Data" options, remember to also change them in all the 
  587. libraries, specifically "libI77a 68K", "libI77b 68K", "libF77 68K", "ANSI 
  588. F2C", "unix F2C", "IOStreams F2C", and "CPlusLib F2C" (the latter two for 
  589. C++ only)
  590.  
  591. I urge all users to read the enclosed AT&T Computing Science Technical 
  592. Report No. 149.  Consider it your compiler and language reference 
  593. manual.  You can print the report by downloading it to any PostScript 
  594. printer.  You can use Apple's LaserWriter Utility application to do 
  595. this or you can use any of the many equivalent utilities.
  596.  
  597.  
  598.  
  599. Part II.  Generating PPC code using Symantec C/C++
  600. ++++++++++++++++++++++++++++++++++++++++++++++++++
  601.  
  602. The C code produced by Mac F2C has the following compile and link 
  603. requirements for generating PPC code using Symantec C/C++:
  604.  
  605.     - the header file "f2c.h"
  606.     - the F2C libraries "libI77 PPC.o" and "libF77 PPC.o"
  607.     - the Mac libraries "InterfaceLib.xcoff" and "MathLib.xcoff"
  608.     - the C libraries "PPCANSI.o", "PPCunix.0", and "PPCRuntime.0"
  609.     - the C++ libraries "PPCIOStreams.o" and "PPCCPlusLib.o" (C++ only)
  610.     - C++ ANSI conformance UNCHECKED (C++ only)
  611.     
  612. In addition, if you compile a stand-alone FORTRAN program (instead of only 
  613. some FORTRAN subroutines) you must include "main.c" in your project (or 
  614. "main.cp" if you use C++; the two files are identical).  This is because 
  615. the original main routine in the FORTRAN program becomes a function that is 
  616. called by main.c.  In addition, main.c performs a series of initializations 
  617. (primarily related to error catching) prior to executing the main FORTRAN 
  618. program.
  619.  
  620. The model project provided ("SPM Mac F2C C Project") is a folder that 
  621. contains everything you need to compile and run code produced by Mac F2C 
  622. using the C compiler.  This folder has a copy of main.c, f2c.h, and a 
  623. project file that includes the appropriate libraries and option settings.
  624.  
  625. The C++ model project ("SPM Mac F2C C++ Project") is a folder that contains 
  626. everything you need to compile and run code produced by Mac F2C using the 
  627. C++ compiler.  This folder has a copy of main.cp, f2c.h, and a project file 
  628. that includes the appropriate libraries and option settings.
  629.     
  630. Create a new project by using the "New Project" command in the Symantec 
  631. Project Manager's "File" menu and selecting "SPM Mac F2C C Project" or "SPM 
  632. Mac F2C C++ Project" as the model for the new project.  Add your code files 
  633. as appropriate, bring it up-to-date (you may need to use the "Make" command 
  634. and the "Use Disk" option the first time), and run.
  635.  
  636. If you compile a FORTRAN subroutine or function that you want to call from 
  637. a C program, look at the C code produced by Mac F2C to see the appropriate 
  638. calling protocol.  You may or may not need to include the F2C support 
  639. libraries ("libF77 PPC.o" and "libI77 PPC.o").  In rare cases, you may also 
  640. need to copy some of the initialization code from "main.c" to your calling 
  641. program.
  642.  
  643. I urge all users to read the enclosed AT&T Computing Science Technical 
  644. Report No. 149.  Consider it your compiler and language reference 
  645. manual.  You can print the report by downloading it to any PostScript 
  646. printer.  You can use Apple's LaserWriter Utility application to do 
  647. this or you can use any of the many equivalent utilities.
  648.  
  649.  
  650.  
  651.